package com.hontech.pastacooking.ext


fun Int.isSetBit(index: Int): Boolean {
    return (this and (0x01 shl index)) != 0
}

fun Int.isClrBit(index: Int) = !this.isSetBit(index)

fun Int.signedValue16(): Int {
    if ((this and 0x8000) != 0) {
        return this - 0x10000
    }
    return this
}

fun Int.unsignedValue16(): Int {
    if (this < 0) {
        return 0x10000 - (-this)
    }
    return this
}
